struct Solution {}

fn main() {}

impl Solution {
    // 时间复杂度O(n*k)，空间复杂度O(1)
    pub fn contains_nearby_duplicate(nums: Vec<i32>, k: i32) -> bool {
        for idx in 0..nums.len() {
            for idx_2 in (idx + 1)..(idx + (k as usize) + 1) {
                if idx_2 >= nums.len() {
                    continue;
                }
                if nums[idx_2] == nums[idx] {
                    return true;
                }
            }
        }
        false
    }
}